#include <bits/stdc++.h>
using namespace std;
void change(int x, int m) {
  if (x == 0)
    return;
  char k = (x % m < 10 ? x % m + '0' : x % m -10+ 'A');
  cout << k;
  change(x / m, m);
}
int main() {
  int x;
  int m;
  cin >> x >> m;
  change(x, m);
  return 0;
}